export function changePswRule(that) {
	const surePswCheck = (rule, value, callback) => {
		if(value === '') {
			callback(new Error('请再次输入密码'));
		} else if(value !== that.pswForm.surePsw) {
			callback(new Error('两次输入密码不一致!'));
		} else {
			callback();
		}
	}

	return {
		oldPsw: [{
			required: true,
			message: '原密码不能为空',
			trigger: 'blur'
		}],
		newPsw: [{
			required: true,
			message: '新密码不能为空',
			trigger: 'blur'
		}],
		surePsw: [{
			required: true,
			validator: surePswCheck,
			trigger: 'blur'
		}]
	}
}

export function ApplicationRule(that) {
	return {
		systemId: [{
			required: true,
			message: '系统ID不能为空',
			trigger: 'blur'
		}],
		appName: [{
			required: true,
			message: '系统名称不能为空',
			trigger: 'blur'
		}],
		projectName: [{
			required: true,
			message: '项目名称不能为空',
			trigger: 'blur'
		}]
	}
}

export function InterfaceRule(that) {
	return {
		apiName: [{
			required: true,
			message: '接口名称不能为空',
			trigger: 'blur'
		}],
		appNames: [{
			required: true,
			type: 'array',
			message: '所属系统不能为空',
			trigger: 'blur'
		}],
		apiAction: [{
			required: true,
			message: '接口Action不能为空',
			trigger: 'blur'
		}],
		apiUrl: [{
			required: true,
			message: '接口路径不能为空',
			trigger: 'blur'
		}]
	}
}

export function ModificationLogRule(that) {
	return {
		apiName: [{
			required: true,
			message: '接口名称不能为空',
			trigger: 'blur'
		}],
		appNames: [{
			required: true,
			type: 'array',
			message: '所属系统不能为空',
			trigger: 'blur'
		}],
		apiAction: [{
			required: true,
			message: '接口Action不能为空',
			trigger: 'blur'
		}],
		apiUrl: [{
			required: true,
			message: '接口路径不能为空',
			trigger: 'blur'
		}]
	}
}

export function ApplicationServiceRule(that) {
	return {
		handlerName: [{
			required: true,
			message: 'handler名称不能为空',
			trigger: 'blur'
		}],
		appNames: [{
			required: true,
			message: '所属系统不能为空',
			trigger: 'blur'
		}],
		handlerPath: [{
			required: true,
			message: 'handler路径不能为空',
			trigger: 'blur'
		}]
	}
}

export function DocumentRule(that) {
	return {
		fileName: [{
			required: true,
			message: '文档描述不能为空',
			trigger: 'blur'
		}],
		appNames: [{
			required: true,
			type: 'array',
			message: '所属系统不能为空',
			trigger: 'blur'
		}]
	}
}

export function UserRule(that) {
	return {
		userName: [{
			required: true,
			message: '用户名不能为空',
			trigger: 'blur'
		}],
		password: [{
			required: true,
			message: '密码不能为空',
			trigger: 'blur'
		}],
		roleId: [{
			required: true,
			message: '角色不能为空',
			trigger: 'change'
		}]
	}
}

export function RoleRule(that) {
	return {
		RoleName: [{
			required: true,
			message: '角色名称不能为空',
			trigger: 'blur'
		}]
	}
}